<template>
  <div>
    <h1>One</h1>
    <p>count:{{ count }}</p>
  </div>
</template>
<script>
import PubSub from 'pubsub-js';
export default {
  name: 'One',
  data() {
    return {
      count: 0,
    };
  },

  /* 
    订阅一般在初始化的时候就已经完成了，未来随时都可以发布
  */
  mounted() {
    PubSub.subscribe('changeCount', (_, num) => {
      console.log('接收到了订阅消息!');
      this.count += num;
    });
  },
};
</script>
<style></style>
